<?php
/**
 * Created by PhpStorm.
 * User: Yan
 * Date: 2017/10/16
 * Time: 13:39
 */

namespace App\Http\Controllers\API;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class PermissionController extends Controller
{
    public function index(Request $request)
    {
        $queryString = $request->get('query', '');
        $models = DB::table('permissions')
            ->where('name', 'like', '%' . $queryString . '%')
            ->get();
        $result=[];
        if($models){
            foreach ($models as $items){
                $result[$items->id]=$items->name;
            }
        }
        return $result;
    }
}